<template>
  <el-form class="content" ref="form" :model="message" label-width="80px" size="mini">
    <el-form-item label="姓名">
      <el-input v-model="message.studentName" style="width: 100px;"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-input v-model="message.studentSex" style="width: 60px;"></el-input>
    </el-form-item>
    <el-form-item label="电话号码">
      <el-input v-model="message.studentTel" style="width: 200px;"></el-input>
    </el-form-item>
    <el-form-item label="邮箱">
      <el-input v-model="message.studentEMail" style="width: 200px;"></el-input>
    </el-form-item>
    <el-form-item size="large">
      <el-button type="primary" @click="onSubmit" >修改</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  import {change} from '@/api/student'
  import {getInfo} from '@/api/user'
    export default {
        name: "index",
      data() {
          return {
            message: {
              studentName: '',
              studentSex: '',
              studentTel: '',
              studentEMail: '',
            }
          }
      },
      created() {
           this.getmessage()
      },
      methods: {
        //预约提示变量 1搜索提示信息 2预约成功提示 3预约失败提示
        open(tips) {
          if (tips == 1) {
            this.$alert('<strong> 信 息 修 改 成 功 。 </strong>', '修改成功！！', {
              dangerouslyUseHTMLString: true
            })
          }else {
            this.$alert('<strong> 信 息 修 改 失 败 。 </strong>', '修改失败！！', {
              dangerouslyUseHTMLString: true
            })
          }
        },
        getmessage() {
          getInfo().then(res => {
            this.message = res.data.userinfo
            // console.log(res.data.userinfo,'请求个人信息成功','message',this.message)
          }).catch(err => {
            console.log(err,'请求个人信息失败')
          })
        },
        onSubmit() {
            change(this.message.studentName,this.message.studentSex,this.message.studentTel,this.message.studentEMail).then(res => {
              this.open(1)
              this.getmessage()
              console.log(res,'修改信息成功打印')
            }).catch(err=> {
              this.open()
              console.log(err,'修改信息失败打印')
            })
        }
      }
    }
</script>

<style scoped>
  .content{
    width: 350px;
    height: 340px;
    padding-left: 30px;
    padding-top: 40px;
    box-shadow: 2px 2px 5px rgba(0,0,0,.6);
    border: 1px solid #CCCCCC;
    margin: 100px auto;

  }

</style>
